/*
 * search_dialog.cpp
 *
 *  Created on: 29.06.2013
 *      Author: SpirTanol
 */

#include "ui/search_dialog.h"
#include "global.h"

// QT
#include <QGridLayout>
#include <QFormLayout>
#include <QPushButton>
#include <QLabel>
#include <QComboBox>
//=========================================================================================
SearchDialog::SearchDialog(QWidget *parent) : QDialog(parent)
{
	setModal(true);
	setFixedSize(0, 0);

	createUI();
	connectSlots();
}

SearchDialog::~SearchDialog()
{

}
//=========================================================================================
void SearchDialog::createUI()
{
	QGridLayout *l = new QGridLayout(this);

	QFormLayout *f = new QFormLayout();
	l->addLayout(f, 0, 0, 1, 2);

	oComboFormat = new QComboBox();
	fillComboFormat(oComboFormat);
	f->addRow(trUtf8("Формат: "), oComboFormat);

	oComboAddr = new QComboBox();
	fillComboAddr(oComboAddr);
	f->addRow(trUtf8("Адрес: "), oComboAddr);

	oBtnOk = new QPushButton(trUtf8("Добавить"));
	l->addWidget(oBtnOk, 1, 0);

	oBtnCancel = new QPushButton(trUtf8("Отмена"));
	l->addWidget(oBtnCancel, 1, 1);
}

void SearchDialog::connectSlots()
{
	connect(oBtnOk, SIGNAL(clicked()), this, SLOT(accept()));
	connect(oBtnCancel, SIGNAL(clicked()), this, SLOT(reject()));
}
//=========================================================================================
int SearchDialog::format() const
{
	return oComboFormat->itemData(oComboFormat->currentIndex(), Qt::UserRole).toInt();
}

int SearchDialog::addr() const
{
	return oComboAddr->itemData(oComboAddr->currentIndex(), Qt::UserRole).toInt();
}
